//
//  FormView.m
//  iBasic
//
//  Created by Andrew Barry on 19/04/08.
//  Copyright 2008 Barry Computer Services. All rights reserved.
//

#import "FormView.h"
#import "FormEditor.h"

@implementation FormView

- (id)initWithFrame:(NSRect)frame {
    self = [super initWithFrame:frame];
	
	NSRect bounds = [self bounds];
    if (self) {
		FormEditorOverlay *overlay = [[FormEditorOverlay alloc] initWithFrame:bounds];
		FormEditor *editor = [[FormEditor alloc] initWithFrame:bounds];
		[editor setFormView:self];
		formEditor = editor;
		formOverlay = overlay;
		[editor setOverlay: overlay];
		
        [self addSubview:editor];
		[self addSubview:overlay];
		
		[formEditor setAutoresizingMask:  NSViewWidthSizable | NSViewHeightSizable];
		[formOverlay setAutoresizingMask:  NSViewWidthSizable | NSViewHeightSizable];
				
//		[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResize:) name:NSViewBoundsDidChangeNotification object:self];
//		[self setPostsBoundsChangedNotifications:YES];
    }
    return self;
}

- (BOOL)isFlipped {
    return YES;
}

-(FormEditor *) getFormEditor {
	return formEditor;
}

- (void)drawRect:(NSRect)rect {
	[[NSColor whiteColor] setFill];
	[NSBezierPath fillRect: rect];

}

/*
-(void)onResize: (NSNotification *) notify {
	printf("onresize\n");
	NSRect bounds = [self bounds];
	[formEditor setFrame:bounds];
	[formOverlay setFrame:bounds];
}
*/
@end
